package com.wdciti.sccp.iot.tsdata.impl.iotdb.util;

import com.wdciti.sccp.iot.tsdata.core.model.DataType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author JINWEN
 */
public class TsDataUtils {

    public static TSDataType getTsDataType(DataType type) {

        switch (type.getType()) {
            case 0:
                return TSDataType.BOOLEAN;
            case 1:
                return TSDataType.INT32;
            case 2:
                return TSDataType.INT64;
            case 3:
                return TSDataType.FLOAT;
            case 4:
                return TSDataType.DOUBLE;
            case 5:
                return TSDataType.TEXT;
            case 6:
                return TSDataType.VECTOR;
            default:
                throw new IllegalArgumentException("Invalid input: " + type);
        }
    }


    public static <T> List<List<T>> asList(T[][] input) {
        List<List<T>> listList = new ArrayList<>();
        Arrays.asList(input).forEach(it -> {
            List<T> list = Arrays.asList(it);
            listList.add(list);
        });
        return listList;
    }


}
